package dao

import (
	"errors"
	__ "shop-microservices/basic/goods_proto"
	"shop-microservices/handler/models"
)

func BrandHotList(in *__.HotSearchListReq) ([]*__.HotSearchList, error) {
	var h models.Hot
	list, err := h.HotList(int(in.Limit))
	if err != nil {
		return nil, errors.New("查询失败")
	}
	var List []*__.HotSearchList
	for _, hot := range list {
		List = append(List, &__.HotSearchList{
			Id:        int64(hot.Id),
			BrandName: hot.BrandName,
			Hot:       int64(hot.Hot),
		})
	}
	return List, err
}
func HotSearchGoodsList(in *__.HotSearchGoodsReq) ([]*__.HotSearchGoodsList, error) {
	var hot models.Hot
	list, err := hot.HotSearchShopList(in.ReqBrandName)
	if err != nil {
		return nil, errors.New("查询失败")
	}
	var List []*__.HotSearchGoodsList
	for _, goodsList := range list {
		List = append(List, &__.HotSearchGoodsList{
			Hot:         goodsList.Hot,
			GoodsName:   goodsList.GoodsName,
			Id:          int64(goodsList.Id),
			GoodsPrice:  float32(goodsList.GoodsPrice),
			BrandName:   goodsList.BrandName,
			GoodsUrl:    goodsList.GoodsUrl,
			GoodsDesc:   goodsList.GoodsDesc,
			GoodsStock:  int64(goodsList.GoodsStock),
			GoodsStatus: int64(goodsList.GoodsStatus),
			Sales:       int64(goodsList.Sales),
			SliderImage: goodsList.SliderImage,
		})
	}
	return List, err
}
